<%@ Page Culture="en-US" UICulture="en-US" Language="C#" Explicit="true" Debug="false"%>

<%@Import Namespace="System" %>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.SqlClient" %>
<%@Import Namespace="System.Data.OleDb" %>
<%@Import Namespace="System.Globalization"%>
<%@Import Namespace="System.Threading"%>


<Script LANGUAGE="C#" runat="server">

  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // To convert the SQL Server versions to MS Access do the following:-
  //   Replace the 2 DSN lines
  //   Replace all code of:-   SQLCommand   to   OleDbCommand
  //   Replace all code of:-   SQLDatareader   to   OleDbDatareader
  //   Replace Dates from '  to #   (do not need ' for SQL Server)   (eg strStartDate = "#" & strStartDate & "#")
  //  Change Function DateConvitfromformUS, also  (see comments in Function itself)
  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


string strErrMsg;
string strPK_ID;
string strPageload;
string strmachine;


//Net 1.1
SqlConnection objConn = new SqlConnection(ConfigurationSettings.AppSettings["DSN"]);
//Net 2.0
//SqlConnection objConn = new SqlConnection(ConfigurationManager.AppSettings["DSN"]);


  //=======================================================================================
  // NOTE:-
  // Code that can be Customised are marked by &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  //
  //=======================================================================================

    void Page_Load() 
    {
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Field data automatic Javascript updating record ability. 
        //NOTE:- Not to be used at all for when doing an Add of a new record(see kgrid_upd.aspx for examples))
        //-------------------------------------------------------------------------------------------------------------------------------------------

        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

          if (!IsPostBack)                //initially coming into this web page from another external web page (eg array_list.aspx)
          {
             strPageload = "setFocus()";        //so as to focus on particular field on the page when loading

             //ProgressBar.Value = "NotWaiting";       //so as to Close progressBar window, if it is shown

            //strdatenow = DateTime.Now;
            strPK_ID = Convert.ToString(Request.QueryString["num"]);     //get PK_ID key
            PK_ID.Value = strPK_ID;                                 //store as hidden variable on form, to keep while in this page
           
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //Get Table record data and display on form, also populating drop-down list, Please change as required
            //--------------------------------------------------------------------------------------------------------------------------
            GetDropDownList();         //so as to make search drop-down initialised   
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
          } 
          else     //when running post back within page 
          {   
             //Do Nothing
             strPageload = "";
            //Response.Write(("Doing Postback within page " + "<br>\""));
           }
       
     }



    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    void GetDropDownList()
    {
        DataTable dt;
        DataRow dr;
        SqlCommand objCmd;
        SqlDataReader objRdr;
        string strdescript;

        // create a temporary DataTable for Machine dropdownlist
        dt = new DataTable();
        dt.Columns.Add(new DataColumn("description", typeof(string)));
        //dt.Columns.Add(new DataColumn("pk_id", GetType(String)));                //Optional if using Key to store in related Tables

        objCmd = new SqlCommand("SELECT description FROM Machine order by description", objConn);
        objConn.Open();

        objRdr = objCmd.ExecuteReader();
        dr = dt.NewRow();
        // initially put found machine for Array first
        dr[0] = strmachine;
        dt.Rows.Add(dr);
        while (objRdr.Read())
        {
            if (objRdr["description"] == null
              || (Convert.ToString(objRdr["description"]).Length == 0))
            {
                strdescript = "";
            }
            else
            {
                strdescript = Convert.ToString(objRdr["description"]);
            }
            if ((strdescript != strmachine))
            {
                dr = dt.NewRow();
                dr[0] = objRdr["description"];
                //dr[1] = objRdr.Item["machine_id"];                   //Optional if using Key to store in related Tables
                dt.Rows.Add(dr);
            }
        }

        //ddldropdown.DataValueField = "pk_id";                   //Optional if using Key to store in related Tables
        ddldropdown.DataValueField = "description";
        ddldropdown.DataTextField = "description";
        ddldropdown.DataSource = dt;
        ddldropdown.DataBind();

        objRdr.Close();
        objConn.Close();
    }
    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



    string dateconvit(DateTime wsDate) {
        // convert create_date to yyyymmdd and dd/mm/yyyy
        string ws_dayy;
        string ws_yearr;
        string ws_monthh;
        string ws_dayit;
        string ws_result_dated;
        //wzz_date = wsDate.ToString("d");

        ws_result_dated = wsDate.ToString("d");

       // Response.Write("This Page is  " + wsDate.ToString() + "<br>");

        //if ((wsDate == null)) {]
        if ((ws_result_dated == null)) {
            return " ";
            //dateconvit = " ";
        }
        else {
           //wss_date = wsDate;
           ws_dayy = Convert.ToString(wsDate.Day);
           //ws_dayy = wsDate.ToString();

            //ws_dayy = datepart("d", wsDate);
            ws_dayit = ws_dayy;
            // response.write("lendate is" & ws_dayit.Length)
            if ((ws_dayit.Length == 1)) {
                ws_dayy = (0 + ws_dayy);
            }
            ws_monthh = Convert.ToString(wsDate.Month);
            //ws_monthh = DatePart("m", wsDate);
            if ((ws_monthh.Length == 1)) {
                ws_monthh = (0 + ws_monthh);
            }
            ws_yearr = Convert.ToString(wsDate.Year);
            //ws_yearr = DatePart("yyyy", wsDate);

            return (ws_dayy + ("/"
                        + (ws_monthh + ("/" + ws_yearr))));


        }
     }


    string DateConvitfromformUS(DateTime wsDate) {
        string stryyyy;
        string strmm;
        string strdd;
        string ws_dateit;
        string ws_len;
        string ws_find_delimiter;
        string ws_find_year;
        string strintermediate_result;
        string ws_result_dated;
        ws_result_dated = wsDate.ToString("d");

        strintermediate_result = "OK";

        if ((ws_result_dated == null)) {
            // DateConvitfromformUS = "NULL"
            strintermediate_result = "NULL";
        }
        else {
            // ===============================================
            // check if year is in yy or yyyy format
            // =============================================== 
            ws_len = Convert.ToString(ws_result_dated.Length);
            ws_find_delimiter = Convert.ToString((ws_result_dated.IndexOf("/", 3) + 1));
            if ((Convert.ToInt32(ws_find_delimiter) > 0)) {
                // OK found delimiter
            }
            else {
                ws_find_delimiter = Convert.ToString((ws_result_dated.IndexOf("-", 3) + 1));
            }
            if ((Convert.ToInt32(ws_find_delimiter) > 0)) {
                ws_find_year = ws_result_dated.Substring(((Convert.ToInt32(ws_find_delimiter) + 1) - 1), (Convert.ToInt32(ws_len) - Convert.ToInt32(ws_find_delimiter)));
                if ((ws_find_year.Length < 4)) {
                    // year is yy format
                    if ((ws_find_year.Length == 1)) {
                        ws_find_year = ("0" + ws_find_year);
                    }
                    if ((ws_find_year.Length == 3)) {
                        ws_find_year = ws_find_year.Substring(1, 2);
                    }
                    if ((Convert.ToInt32(ws_find_year) < 30)) {
                        // assume 2000 century if year less than 30
                        ws_find_year = ("20" + ws_find_year);
                    }
                    else {
                        ws_find_year = ("19" + ws_find_year);
                    }
                    ws_dateit = (ws_result_dated.Substring(0, Convert.ToInt32(ws_find_delimiter)) + Convert.ToInt32(ws_find_year));
                }
            }
            else {
                // DateConvitfromformUS = "NULL"
                strintermediate_result = "NULL";
            }
            // =================================================
            // End year check
            // =================================================
            // If DateConvitfromformUS = "NULL" Then
            if ((strintermediate_result == "NULL")) {
                // do nothing
            }
            else {
                stryyyy = Convert.ToString(wsDate.Year);
                //Response.Write("stryyyy  " + stryyyy  + "<br>");
                //stryyyy = DatePart("yyyy", wsDate);
                strmm = Convert.ToString(wsDate.Month);
                //strmm = DatePart("m", wsDate);
                if ((strmm.Length == 1)) {
                    strmm = (0 + strmm);
                }
                strdd = Convert.ToString(wsDate.Day);
                //strdd = DatePart("d", wsDate);
                if ((strdd.Length == 1)) {
                    strdd = (0 + strdd);
                }
                //Response.Write("strdd  " + strdd  + "<br>");
                //Response.Write("strmm  " + strmm  + "<br>");

                //Next 10 lines are MS Access code only
                //if ((Convert.ToInt32(strdd) > 12)) {
                    // will force what it thinks is a Month, a DAY
                  //  ws_dateit = (strdd + ("/" 
                    //            + (strmm + ("/" + stryyyy))));
                    // now US Format
                //}
                //else {
                //    ws_dateit = (strmm + ("/" 
                //                + (strdd + ("/" + stryyyy))));
                    // now US Format
                //}
           
                //Next line is SQL Server code only
                ws_dateit = ("cast(\'" + (stryyyy + (strmm + (strdd + "\' as DateTime)"))));

                strintermediate_result = ws_dateit;
            }
      
        }
        return strintermediate_result;
    }
  
</Script> 



<HTML>
<HEAD>
<TITLE>ARRAY Title</TITLE>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="imagetoolbar" CONTENT="NO">


<Script LANGUAGE="JavaScript" src="ajax_xmlhttp.js">
</Script>
<Script LANGUAGE="JavaScript" src="scw.js">
</Script>

<Script LANGUAGE="JavaScript">
<!--

//==============================================================================================================
//NEXT Part is AJAX Remote Scripting +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//==============================================================================================================

 function show_savepage(actionit, indxk, sortby, row_ID, page_ID, skipcount, pagesize, machchanged, arraychanged, sdatechanged)
 {                       
                   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                   //Change ajax called program name (ie AJAX_UPD)
                   var requestURLIT = 'ajax_kgrid_add.aspx?action=' + actionit
                   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                   var url = requestURLIT + '&num=' + indxk + '&sortby=' + sortby + '&rowid=' + row_ID + '&pageid=' + page_ID + '&skip=' + skipcount
                   url = url + '&pagesize=' + pagesize

                   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                   // May have to add other datagrid Search criteria

                   //Add Search criteria next here (NOTE:- If Not using datagrid frame in conjunction, then DO NOT Use)
                   url = url + '&arraysearch=' +   parent.document.getElementById('textsearch').value
                   //url = url + '&machsearch=' +   parent.document.getElementById('ddldropdown').value
                   //...................................................................................................................................................................................................

                   //Add Field Data to be saved here (put escape on all text fields)
                   url = url + '&machtosave=' + escape(document.getElementById('ddldropdown').value)
                   url = url + '&arraytosave=' + escape(document.getElementById('textarray').value)
                   url = url + '&startdatetosave=' + document.getElementById('textsdate').value
                   url = url + '&enddatetosave=' + escape(document.getElementById('textedate').value)
                   url = url + '&notetosave=' + escape(document.getElementById('textnote').value)
                   url = url + '&chktosave=' + document.getElementById('check1').checked
                   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

                   //alert("url is " + url);
	   xmlHttp = GetXmlHttpObject(stateChangeHandlerSAVE); 
	   xmlHttp_Get(xmlHttp, url); 
 }


//Next function is just for delaying the Error Message a bit
//------------------------------------------------------------------------
function ShowAlert(str1) 
{ 
 alert(str1); 
}

//=======================================================================================================================================================
// Next functions are run after the above functions, so as to see when the Remote page has been completed
// stateChangeHandler will fire when the state has changed, i.e. data is received back 
// This is non-blocking (asynchronous) 
//=======================================================================================================================================================
function stateChangeHandlerSAVE() 
{ 
                                          var rowID1;
			//readyState of 4 or 'complete' represents that data has been returned 
		           if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
                                           { 
		             //Gather the results from the callback 
		             var str = xmlHttp.responseText; 
                                             //alert(str);     
                                             //document.getElementById("ProgressBar").value = "NOTwaiting";
                                              //Next 2 lines stop Progress Bar in Grid frame
                                              parent.document.getElementById("pnlpopupprogress").style.display = "none";
                                              //parent.document.getElementById('overlayprogress').style.visibility="hidden";


                                             //If validation Error found, then display error concerned
                                             if (str.substring(0,5) == "Error")
                                             {
                                                setTimeout("ShowAlert(' " + str + " ')",100)     //so as to allow ProgressBar to finish(for Netscape)
                                                //alert(str);      
                                             }
                                             else
                                             {

                                               parent.document.getElementById("pnlpopupprogress").style.display = "none";
                                               parent.document.getElementById('overlayprogress').style.visibility="hidden";

                                               if (str == "")     //only saving field not part of datagrid
                                                {
                                                   //do nothing
                                                }  
                                               else
                                                {
                                                  //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                                                  //The next Part is you are using a datagrid LIST inconjunction (so can be taken out for standalone update form)
                                                  //------------------------------------------------------------------------------------------------------------------------

                                                  parent.document.getElementById('nameList2').innerHTML = str;
                                                  rowID1 = parent.document.getElementById('RowIDGet').value;
                                                 //alert("rowID1 is " + rowID1);

                                                 //Check if Search Criteria should be made blank, ie have changed a search criteria field(so do reload)
                                                 if (parent.document.getElementById('chkresetcriteria').value  == ' True ')
                                                 {
                                                    //parent.ARRAYSLIST.document.form1.ddldropdown.options[0].selected = true;    //Note: Must have values in dropdown to work
                                                    parent.document.getElementById('textsearch').value = "";
                                                 }

                                                 parent.resetablebg();
                                                //set column sort header to a different background color
                                                parent.setBgColor(parent.document.getElementById('SortFieldGet').value);
                                                var table = parent.document.getElementById('myTable');
                                                if (table)   
                                                {
                                                 //Highlight 1st Row of new Page
                                                 table.rows[rowID1].style.backgroundColor="#F3F3F3";
                                                 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                                                 //Highlight Input Textbox row as well (Comment out if no Input Textbox used in List)
                                                 //parent.ARRAYSLIST.document.getElementById('aa' + rowID1 + 'c7').style.backgroundColor="silver";
                                                 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                                                //alert("about to Close");
                                                 CloseUpd ();
                                                }   
                                                //------------------------------------------------------------------------------------------------------------------------
                                                //END of Part if using a datagrid LIST inconjunction (so can be taken out for standalone update form
                                               //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

                                               


                                               }  //if (str == "")

                                             }   // if (str.substring(0,5) == "Error")


		           }    // if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')

} 



//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//The following 2 functions are only used if having datagrid LIST being used in conjunction, so takeout for standalone
//----------------------------------------------------------------------------------------------------------------------------------------------------------------
function resetablebg()
{
 var table = parent.document.getElementById('myTable');

 if (table)   
  {
   //Make all rows white again
   for (var r = 0; r < table.rows.length; r++)
   {
     table.rows[r].style.backgroundColor="white";
     //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
     //Reset Input Textbox row as well (Comment out if no Input Textbox used in List)
     //parent.document.getElementById('aa' + r + 'c7').style.backgroundColor="white";
     //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   }
  }             
}
function setBgColor(id) 
{
  //alert("in setBgcolor");
 var table = parent.document.getElementById(id);

 if (table)
  {
     parent.document.getElementById(id).style.backgroundColor = "blue";
  }
}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//Please change as required
//------------------------------------------------------------------------------------------------------------------------------------------
function setFocus()
{
    //document.getElementById('ddldropdown').focus();

}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//Please change as required
//---------------------------------------------------------------------------------------------------------------------------------------------
function SaveClick(action)
{
 //alert("Clicked on SAVE button2");
 var indxk = document.getElementById('PK_ID').value;  //PKID

 var row_ID = 0;
 var skipcount = 0;
 var sortby = "";
 var pagesize = 0;
 var page_ID = 0;
 //Please change next 3 lines as required (ie Datagrid list Search and Sort fields)
 var MachChanged = 0;
 var ArrayChanged = 0;
 var SdateChanged = 0;
 //Please change next 3 lines as required (ie Datagrid list Search and Sort fields)
 var machtosave = "";
 var arraytosave = "";
 var startdatetosave = "";

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//The following lines are when there is a LIST used in conjunction, take out for standalone
 row_ID = parent.document.getElementById('RowIDGet').value;
 skipcount = parent.document.getElementById('SkipCount').value;
 sortby = parent.document.getElementById('SortFieldGet').value;
 pagesize = parent.document.getElementById('PageSizeGet').value;
 page_ID = parent.document.getElementById('CurrentPageGet').value;  
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//NOTE:- Take out for standalone

 //if (action != "byitself")    //ie refreshing grid list again
 //if (page_ID > 5)
 //{
  //ShowProgressBar();
   parent.document.getElementById("pnlpopupprogress").style.display = "block";
   parent.document.getElementById('overlayprogress').style.visibility="visible";
 //}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//Please amend second line of next, for Search and Sort fields. NOTE:- Can leave as is for standalone
//--------------------------------------------------------------------------------------------------------------------------------------
 show_savepage(action, indxk, sortby, row_ID, page_ID, skipcount, pagesize);
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

}




//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//OPTIONAL if using a Secondary link list. Can leave in.
//---------------------------------------------------------------------------------------------------------------------
function SubList()
{
 //OPTIONAL:- Display secondary sub List of Clients page on this same window

//document.location.href="VIEW_CLIENT_ARRAY_LIST.aspx?action=upd" +
//                             "&initlinkid=" + document.getElementById('PK_ID').value
                         
}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&




//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Open modal pop-up windows
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var modalWinaddpopup

function IgnoreEvents(e)
{
  return false;
}


function machlist()
{
 //alert("Machine List"); 
 checkblur = "True";     //only need this if this window is itself a MODAL popup

  if(navigator.appName == "Microsoft Internet Explorer")
   {
    modalWinaddpopup = open('machine_list.aspx?action=init','MACHLIST','height=300,width=380,left=283,top=120,toolbar=0,menubar=0,location=0,scrollbars=0');
    modalWinaddpopup.focus();

    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    //window.parent.ARRAYSUPD.attachEvent("onfocus", HandleFocus); 
    //window.parent.ARRAYSLIST.attachEvent("onfocus", HandleFocus); 

    document.getElementById('overlay').style.visibility="visible";
    window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="visible";
    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   }
  else    //Not IE
   {
    modalWinaddpopup = open("machine_list.aspx?action=init&num="
            , "MACHLIST",
            "dialog=yes,modal=yes,dependent=yes,alwaysraised=yes,top=420,left=283,width=380,height=300");
     modalWinaddpopup.focus();

     //NOTE ===========================================================================================
     //Next line is for Firefox 2.0, as modal and dependent need more priveleges
     //netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
     //================================================================================================

    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    //window.parent.ARRAYSUPD.addEventListener("focus", HandleFocus, false); 
    //window.parent.ARRAYSLIST.addEventListener("focus", HandleFocus, false); 

    document.getElementById('overlay').style.visibility="visible";
    window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="visible";
    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   }

}


function calstartpopup()
{
  //alert("calstartpopup"); 
  checkblur = "True";     //only need this if this window is itself a MODAL popup

  if(navigator.appName == "Microsoft Internet Explorer")
   {
    modalWinaddpopup =window.open('myCalendar.aspx?textbox=textsdate&textlabel=Start Date' , 'MYCAL','height=260,width=230,left=183,top=350,toolbar=0,menubar=0,location=0,scrollbars=0');
    modalWinaddpopup.opener = self;

    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    document.getElementById('overlay').style.visibility="visible";
    window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="visible";
    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   }
  else    //Not IE
   {

    //NOTE ===========================================================================================
    //Next lines are for Firefox 2.0, as modal and dependent need more privileges
    try {
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
	} catch (err) {   
		//document.write("Sorry, you can not enjoy this site because of " +err+ ".");
                            alert("Cannot show Modal Popup");  
		return false;
	}

    modalWinaddpopup = open("myCalendar.aspx?textbox=textsdate&textlabel=Start Date"
            , "MYCAL",
            "dialog=yes,modal=yes,dependent=yes,alwaysraised=yes,top=350,left=183,width=230,height=260");
    modalWinaddpopup.focus();

     //NOTE ===========================================================================================
     //Next line is for Firefox 2.0, as modal and dependent need more priveleges
     //netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
     //================================================================================================
    
    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  
    //document.getElementById('overlay').style.visibility="visible";
    //window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="visible";
    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   }

}


function calendpopup()
{
  //alert("calendpopup"); 
  checkblur = "True";     //only need this if this window is itself a MODAL popup
 
  if(navigator.appName == "Microsoft Internet Explorer")
   {
    modalWinaddpopup =window.open('myCalendar.aspx?textbox=textedate&textlabel=End Date' , 'MYCAL','height=235,width=230,left=183,top=350,toolbar=0,menubar=0,location=0,scrollbars=0');
    modalWinaddpopup.opener = self;

    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   
    document.getElementById('overlay').style.visibility="visible";
    window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="visible";
    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   }
  else    //Not IE
   {

    //NOTE ===========================================================================================
    //Next lines are for Firefox 2.0, as modal and dependent need more privileges
    try {
		netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
	} catch (err) {   
		//document.write("Sorry, you can not enjoy this site because of " +err+ ".");
                            alert("Cannot show Modal Popup");  
		return false;
	}

    modalWinaddpopup = open("myCalendar.aspx?textbox=textedate&textlabel=End Date"
            , "MYCAL",
            "dialog=yes,modal=yes,dependent=yes,alwaysraised=yes,top=350,left=183,width=230,height=235");
    modalWinaddpopup.focus();
    
     //NOTE ===========================================================================================
     //Next line is for Firefox 2.0, as modal and dependent need more priveleges
     //netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
     //================================================================================================

    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   
    //document.getElementById('overlay').style.visibility="visible";
    //window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="visible";
    //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
   }

}



function FocusClick()
{
document.getElementById('tempinit').focus();  
document.getElementById('overlay').style.visibility="hidden";         
window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="hidden";
}

function KeepFocusClick()
{
document.getElementById('overlay').style.visibility="visible";
window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="visible";
}


function SaveCalendarClick()
{
   document.getElementById('overlay').style.visibility="hidden";
   window.parent.ARRAYSLIST.document.getElementById('overlay').style.visibility="hidden";
   SaveClick('refresh');
}
 

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// END of Open modal pop-up windows
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//REFRESH Page 
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="0:10"

if (document.images)
 {
  var parselimit=limit.split(":")
  parselimit=parselimit[0]*60+parselimit[1]*1
 }

function Beginrefresh()
{
 if (!document.images)
  return

  if (parselimit==1)
  {
    //Redisplay Page again
    // other action is - SearchResetPage
     //alert("Refreshing Page");
     limit="0:10";
     parselimit=limit.split(":");
     parselimit=parselimit[0]*60+parselimit[1]*1;
     Beginrefresh();

     //Checking for key fields in datagrid frame, Do Not need if standalone
     if(!parent.ARRAYSLIST.document.getElementById('RowIDGet'))
       return
     if(!parent.ARRAYSLIST.document.getElementById('CurrentPageGet'))
       return
     if(!parent.ARRAYSLIST.document.getElementById('SkipCount'))
       return
     if(!parent.ARRAYSLIST.document.getElementById('PageSizeGet'))
       return

       if(parent.ARRAYSLIST.document.getElementById('SortFieldGet'))
       {
         var indx1 = document.getElementById('PK_ID').value;  
         //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
         //NOTE:- If Not using datagrid frame, then set action1 = byitself   
         //var action1 = "byitself";     //for when no datagrid inconjunction
         var action1 = "GetCurrentPage";
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 
        //check_records(action1, indx1);
       }

     //Following is old code to do Page Reload
    //window.location.reload()
  }
  else
   { 
    parselimit-=1
    curmin=Math.floor(parselimit/60)
    cursec=parselimit%60
    if (curmin!=0)
     curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
    else
     curtime=cursec+" seconds left until page refresh!"

   window.status=curtime
   //1000 milliseconds, which is 1 second.
   setTimeout("Beginrefresh()",1000)
  }
}



function CloseUpd () 
{
   parent.CloseUpd();
}


//--> 
</Script>


</HEAD>


<!--&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&-->
<!-- If not using check update of record by another user, then do not use next line -->
<!--BODY bgColor=white onFocus="checkPop()" onClick="checkPop()" onload="<=strPageload>;Beginrefresh();">-->
<BODY bgColor=white onload="<%=strPageload%>">
<!--&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&-->


<form id="form1" method="post" runat="server">

<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<!-- Storing HIDDEN variables (MANDATORY) -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<!-- next 3 are ASP.NET type hidden variables -->

<!-- next line is Optional (used so as to see at bottom of form)-->
<br><br><br><br><br><br><br><br><br><br>

<!--Next variable is for Modal POP-UP Add only, so as to focus initially--> 
<asp:TextBox id="tempinit"
           style="POSITION: absolute; 
                       BORDER-TOP: 0px solid black;
                      TOP: 1px; 
                      LEFT: 1px;  
                      BORDER-BOTTOM: 0px solid black;
                      BORDER-LEFT: 0px solid black;
                      BORDER-RIGHT: 0px solid black"
     readonly="true"
      tabIndex="-1"
      runat="server" 
     AutoCompleteType="Disabled">
</asp:TextBox>

<input id=PK_ID style="VISIBILITY: hidden" 
        type="text" runat="server" />

<input id=AUTH_USER style="VISIBILITY: hidden" 
        type="text" value="<%=Request.ServerVariables["AUTH_USER"]%>" 
>
<input id=REMOTE_ADDR style="VISIBILITY: hidden" 
        type="text" value="<%=Request.ServerVariables["REMOTE_ADDR"]%>" 
>

<!-- next Hidden variable is for displaying the Progress Bar via Javascript -->
<input id=ProgressBar style="VISIBILITY: hidden" 
        type="text" runat="server" />
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<!-- END Storing HIDDEN variables (MANDATORY) -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->


<!-- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&-->
<!-- Storing HIDDEN variables (Customise) for checking for change in Sort and Search fields value -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<input id=ArrayName style="VISIBILITY: hidden" 
        type="text" runat="server" />
<input id=MachineName style="VISIBILITY: hidden" 
        type="text" runat="server" />
<input id=StartDateCheck style="VISIBILITY: hidden" 
        type="text" runat="server" />
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<!-- END Storing HIDDEN variables (Customise) for checking for change in field value -->
<!-- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&-->

<div id=overlay style="POSITION: absolute; 
             LEFT: 1px;  
             VISIBILITY: hidden;
             TOP: 1px; 
             HEIGHT: 900px;
             WIDTH: 900px;
             Z-INDEX: 300"> 
      <img src="images/PNG_1000x1000.png" alt="" />
</div>



<span style="POSITION: absolute; 
             LEFT: 240px;  
             TOP: 4px; 
             HEIGHT: 30px;
             WIDTH: 200px;
             BACKGROUND-COLOR: white;
             COLOR: #396DA3;
             FONT-WEIGHT: bold;
             FONT-SIZE: 14px; 
             FONT-FAMILY: arial; 
             FONT-STYLE: normal; 
             Z-INDEX: 2">  
 Array Details
</span>



 <div style="position: absolute; left: 1px; top: 1px; z-index: 100;">     
          <input id="Button344" type="button"  onclick="SaveClick()" style="text-align:center;width: 60px;"
           value="Add" />
</div>   

 <div style="position: absolute; left: 62px; top: 1px; z-index: 100;">     
          <input id="Button345" type="button"  onclick="CloseUpd()" style="text-align:center; color: #FF0000;"
           value="Cancel" />
</div>   



        <!--Close Button using only Javascript-->
        <span style="position: absolute; visibility: visible; left: 580px; top: 1px; z-index: 100">
            <a href="javascript:CloseUpd()">
                <img src="images/Close-image2.jpg" alt="Close" width="19" height="21" border="0">
            </a>
        </span>



<!--Start of Machine field-->            
<asp:Label id="Machine" 
             style="FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 118px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 48px; 
                    BACKGROUND-COLOR: white" 
                    runat="server" height="21" width="100">
               Machine:
</asp:Label>
    

<asp:DropDownList id="ddldropdown" 
     style="POSITION: absolute; 
            LEFT: 171px;  
            TOP: 46px; 
            HEIGHT: 19px;
            WIDTH: 110px;
            BACKGROUND-COLOR: white;
            COLOR: brown;
            FONT-WEIGHT: bold;
            FONT-SIZE: 12px; 
            FONT-FAMILY: arial; 
            FONT-STYLE: normal; 
            Z-INDEX: 100"    
     tabIndex="1"
     runat="server">
</asp:DropDownList>



<asp:Label id="lblarray" 
             style="FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 357px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 48px; 
                    BACKGROUND-COLOR: white" 
                    runat="server" height="21" width="100">
               Array:
</asp:Label>  

<asp:TextBox id="textarray" 
      style="POSITION: absolute; 
             LEFT: 393px;  
             TOP: 46px; 
             HEIGHT: 20px;
             WIDTH: 145px;
             BACKGROUND-COLOR: white;
             COLOR: black;
             FONT-WEIGHT: bold;
             FONT-SIZE: 12px; 
             FONT-FAMILY: arial; 
             FONT-STYLE: normal; 
             Z-INDEX: 100"       

      tabIndex="2"
      readonly="false"
      runat="server">
</asp:TextBox>



<span style="POSITION: absolute; 
               LEFT: 79px; 
               TOP: 74px;  
               Z-INDEX: 100">
   <a href='#' onclick='scwShow(textsdate,event);return false;'>
      <img SRC="images/calendar1.bmp" ALT="Select Date" 
     WIDTH="28" HEIGHT="28" border="0">
   </a>
</span>
<asp:Label id="StartDate" 
             style="FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 109px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 78px; 
                    BACKGROUND-COLOR: white" 
                    runat="server" height="21" width="100">
               Start Date: 
</asp:Label>     

<asp:TextBox id="textsdate" 
      style="POSITION: absolute; 
             LEFT: 171px;  
             TOP: 76px; 
             HEIGHT: 19px;
             WIDTH: 70px;
             BACKGROUND-COLOR: white;
             COLOR: black;
             FONT-WEIGHT: normal;
             FONT-SIZE: 11px; 
             FONT-FAMILY: arial; 
             FONT-STYLE: normal; 
             Z-INDEX: 100"       
      tabIndex="3"
      runat="server">
</asp:TextBox>



<span style="POSITION: absolute; 
               LEFT: 305px; 
               TOP: 74px;  
               Z-INDEX: 100">
   <a href='#' onclick='scwShow(textedate,event);return false;'>
      <img SRC="images/calendar1.bmp" ALT="Select Date" 
     WIDTH="28" HEIGHT="28" border="0">
   </a>
</span>
<asp:Label id="EndDate" 
             style="FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 338px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 78px; 
                    BACKGROUND-COLOR: white" 
                    runat="server" height="21" width="100">
               End Date:
</asp:Label>     

<asp:TextBox id="textedate" 
      style="POSITION: absolute; 
             LEFT: 393px;  
             TOP: 76px; 
             HEIGHT: 19px;
             WIDTH: 70px;
             BACKGROUND-COLOR: white;
             COLOR: black;
             FONT-WEIGHT: normal;
             FONT-SIZE: 11px; 
             FONT-FAMILY: arial; 
             FONT-STYLE: normal; 
             Z-INDEX: 100"       
      tabIndex="4"
      runat="server">
</asp:TextBox>



<asp:Label id="lblnotes" 
             style="FONT-WEIGHT: bold; 
                    FONT-SIZE: 12px; 
                    Z-INDEX: 100; 
                    LEFT: 130px; 
                    COLOR: black; 
                    FONT-STYLE: normal; 
                    FONT-FAMILY: arial; 
                    POSITION: absolute; 
                    TOP: 117px; 
                    BACKGROUND-COLOR: white" 
                    runat="server" height="21" width="75">
               Notes:
</asp:Label>  
                 
<asp:TextBox id="textnote" 
     style="HEIGHT: 45px; 
            LEFT: 171px; 
            FONT-SIZE: 12px; 
            COLOR: Blue; 
            FONT-FAMILY: arial;
            POSITION: absolute; 
            TOP: 117px; 
            WIDTH: 270px; 
            Z-INDEX: 100" 

     tabIndex="5"
     runat="server" 
     TextMode="MultiLine">
</asp:TextBox>
           

<asp:CheckBox id="check1" 
     style="HEIGHT: 50px; 
            LEFT: 71px; 
            FONT-SIZE: 12px; 
            COLOR: Blue; 
            FONT-FAMILY: arial;
            POSITION: absolute; 
            TOP: 170px; 
            WIDTH: 270px; 
            Z-INDEX: 100" 

     Text="Completed?" TextAlign="Left"
     tabIndex="6"
     runat="server">
</asp:CheckBox>
                  

<div id="nameList2">

</div>



</FORM>


</BODY>
</HTML>


